import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class Test10 extends StatefulWidget {
  @override
  _Test10State createState() => _Test10State();
}

class _Test10State extends State<Test10> {
  var index=0;
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          SizedBox(height:50),
          _buildCenter(),
          SizedBox(height:50),
          _buildBottom(),
        ],
      ),
    );
  }

  IndexedStack _buildCenter() {
    return IndexedStack(
      index: index,
      children: [
        Container(
          height: 300,
          width: 300,
          color: Colors.red,
          child: Center(
            child: Icon(Icons.ac_unit_sharp,size: 60,color: Colors.blue,),
          ),
        ),
        Container(
          height: 300,
          width: 300,
          color: Colors.red,
          child: Center(
            child: Icon(Icons.access_alarm,size: 60,color: Colors.blue,),
          ),
        ),
        Container(
          height: 300,
          width: 300,
          color: Colors.red,
          child: Center(
            child: Icon(Icons.backpack,size: 60,color: Colors.blue,),
          ),
        ),
      ],
    );
  }

  Center _buildBottom() {
    return Center(
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          IconButton(icon: Icon(Icons.ac_unit_sharp), onPressed: (){
            setState(() {
              index=0;
            });
          }),
          IconButton(icon: Icon(Icons.access_alarm), onPressed: (){
            setState(() {
              index=1;
            });
          }),
          IconButton(icon: Icon(Icons.backpack), onPressed: (){
            setState(() {
              index=2;
            });
          }),
        ],
      ),
    );
  }
}
